package com.kongxx.wicketstudy.component.link;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.IModel;

public class LinkExample extends WebPage {

	private static Log log = LogFactory.getLog(LinkExample.class);
	
	private int count = 0;

	public LinkExample() {
		log.info("Constructor");

		Link link = new Link("myLink") {
			public void onClick() {
				log.info("count: " + count);
				count++;
			}
		};
		link.add(new Label("myCount", new IModel() {
			public Object getObject(Component component) {
				return Integer.toString(count);
			}

			public Object getObject() {
				return Integer.toString(count);
			}

			public void setObject(Object arg0) {
				
			}

			public void detach() {
				
			}
		}));
		add(link);
	}
}
